Skip to content

fix(migrate): honor @onDelete/@onUpdate declared on identity.reference#65

Merged
dmealing merged 1 commit into
mainfrom
fix/migrate-identity-reference-ondelete
Jun 21, 2026
Merged

fix(migrate): honor @onDelete/@onUpdate declared on identity.reference#65
dmealing merged 1 commit into
mainfrom
fix/migrate-identity-reference-ondelete

Conversation

@dmealing

Copy link
Copy Markdown
Member

Problem

meta migrate resolved FK referential actions only from a correlated relationship node. An @onDelete/@onUpdate authored directly on the identity.reference — which is the construct that defines the FK — was silently ignored. A reference declared @onDelete: cascade emitted a bare FK (no ON DELETE clause), silently dropping cascade intent.

Surfaced on a real model where ~150 FKs declare @onDelete on identity.reference: the generated baseline emitted 2 ON DELETE clauses instead of ~150, breaking cascading deletes at runtime.

Fix

  • resolveReferentialActions precedence is now: (1) action declared on the identity.reference; (2) correlated relationship's explicit action / subtype default; (3) none.
  • MetaReferenceIdentity gains onDelete / onUpdate getters (mirrors MetaRelationship).
  • "setnull" accepted as an alias for canonical "set-null".

Tests

  • Reference-level resolve cases (with/without relationship, override precedence, setnull alias).
  • End-to-end: identity.reference @onDelete: cascadeON DELETE CASCADE in emitted Postgres DDL.
  • Full metadata + migrate-ts suites green (2559 pass, 0 fail).

🤖 Generated with Claude Code

`meta migrate` only resolved FK referential actions from a correlated
`relationship` node — an `@onDelete`/`@onUpdate` authored directly on the
`identity.reference` (which IS the FK) was silently ignored, so a reference
declared `@onDelete: cascade` emitted a bare FK with no ON DELETE clause.

resolveReferentialActions now reads the action from the reference first, then
falls back to a correlated relationship's explicit action / subtype default.
MetaReferenceIdentity gains `onDelete`/`onUpdate` getters. "setnull" is accepted
as an alias for the canonical "set-null".

Adds reference-level regression tests (resolve + end-to-end Postgres DDL).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018mjBXyYKk6tbQymzhgMmdB
@dmealing
dmealing enabled auto-merge June 21, 2026 21:18
@dmealing
dmealing merged commit 574d9e8 into main Jun 21, 2026
29 checks passed
@dmealing
dmealing deleted the fix/migrate-identity-reference-ondelete branch June 21, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant